//
//  UserNotificationManager.h
//  AgendaManager
//
//  Created by 黄世淞 on 2018/5/28.
//  Copyright © 2018年 黄世淞. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UserNotifications/UserNotifications.h>
#define ActionFiveMin @"fiveMinete" //5分钟
#define ActionHalfAnHour @"halfAnHour"//30分钟
#define ActionOneHour @"oneHour"//一小时后
#define ActionStop @"stopCancel"//停止
//
#define CategryLaterIdf @"categryIdentiferLater"//稍后执行
#define CategryStopIdf @"categryIdentiferStop"//停止
//
#define isLater @"isLater"
#define NotificationIdentifer(identifer) [NSString stringWithFormat:@"%@_%@",isLater,identifer];
@interface UserNotificationManager : NSObject

/**
 注册本地通知
 */
+ (void)registerLocalNotification;
#pragma mark --- addNotification

/**
 添加通知

 @param request 通知请求
 */
+ (void)addNotificationWithRequest:(UNNotificationRequest *)request
                 completionHandler:(void(^)(NSError * error))handler;


/**
 添加通知

 @param content 通知内容
 @param identifer 通知标识符
 @param trigger 通知触发器
 */
+ (void)addNotificationWithContent:(UNNotificationContent *)content
                         identifer:(NSString *)identifer
                           trigger:(UNNotificationTrigger *)trigger
                 completionHandler:(void (^)(NSError * error))handler;

/**
 添加通知

 @param content 通知内容
 @param interval 通知间隔
 @param identifer 通知标识符
 @param isRepeat 是否重复
 */
+ (void)addNotificationWithContent:(UNNotificationContent *)content
                          interval:(NSTimeInterval)interval
                         identifer:(NSString *)identifer
                          isRepeat:(BOOL)isRepeat
                 completionHandler:(void (^)(NSError * error))handler;

/**
 添加通知

 @param content 通知内容
 @param identifer 通知标识符
 @param isRepeat 是否重复
 @param dateComponents 日期组件
 */
+ (void)addNotificationWithContent:(UNNotificationContent *)content
                         identifer:(NSString *)identifer
                          isRepeat:(BOOL)isRepeat
                    dateComponents:(NSDateComponents *)dateComponents
                 completionHandler:(void (^)(NSError * error))handler;

/**
 添加通知

 @param content 通知内容
 @param identifer 通知标识符
 @param isRepeat 是否重复
 @param date 日期
 @param weekDay 星期几
 */
+ (void)addNotificationWithContent:(UNNotificationContent *)content
                         identifer:(NSString *)identifer
                          isRepeat:(BOOL)isRepeat
                              date:(NSDate *)date
                           weekDay:(NSInteger)weekDay
                 completionHandler:(void (^)(NSError * error))handler;

/**
 添加通知

 @param body 通知主体
 @param title 通知标题
 @param subTitle 通知子标题
 @param weekDay 星期几
 @param date 日期
 @param music 音乐
 @param identifer 标识符
 @param isRepeat 是否重复
 */
+ (void)addNotificationWithBody:(NSString *)body
                          title:(NSString *)title
                       subTitle:(NSString *)subTitle
                        weekDay:(NSInteger)weekDay
                           date:(NSDate *)date
                          music:(NSString *)music
                      identifer:(NSString *)identifer
                       isRepeat:(BOOL)isRepeat
              completionHandler:(void (^)(NSError * error))handler;
#pragma mark --- NotificationManage

/**
 移除一个指定的通知

 @param identifer 标识符
 */
+ (void)removeNotificationWithIdentifer:(NSString *)identifer;

/**
 移除所有通知
 */
+ (void)removeAllNotification;

/**
 移除多个通知

 @param identifers 多个标识符数组
 */
+ (void)removeNotificationWithIdentifers:(NSArray <NSString *>*)identifers;

/**
 判断某个通知是否存在

 @param identifer 标识符
 @param completion 判断结果
 */
+ (void)notificationIsExitWithIdentifer:(NSString *)identifer completion:(void (^)(BOOL isExit))completion;

/**
 获取所有通知的标识符
 */
+ (void)getAllNotificationIdentiferBlock:(void(^)(NSArray <NSString *> * identifers))idBlock;

/**
 获取已交付的标识符
 */
+ (void)getDeliveredNotificationIdentiferBlock:(void(^)(NSArray <NSString *> * identifers))idBlock;

/**
 获取的标识符
 */
+ (void)getPendingNotificationIdentiferBlock:(void(^)(NSArray <NSString *> * identifers))idBlock;
#pragma mark --- UNNotificationContent

/**
 通知内容

 @param title 标题
 @param subTitle 子标题
 @param body 主体
 */
+ (UNMutableNotificationContent *)contentWithTitle:(NSString *)title
                                          subTitle:(NSString *)subTitle
                                              body:(NSString *)body;

/**
 @param badge 标记
 */
+ (UNMutableNotificationContent *)contentWithTitle:(NSString *)title
                                          subTitle:(NSString *)subTitle
                                              body:(NSString *)body
                                             badge:(NSInteger)badge;
/**
 @param sound 声音
 */
+ (UNMutableNotificationContent *)contentWithTitle:(NSString *)title
                                          subTitle:(NSString *)subTitle
                                              body:(NSString *)body
                                             sound:(UNNotificationSound *)sound;
+ (UNMutableNotificationContent *)contentWithTitle:(NSString *)title
                                          subTitle:(NSString *)subTitle
                                              body:(NSString *)body
                                             badge:(NSInteger)badge
                                             sound:(UNNotificationSound *)sound;
/**
 @param attachment 附件
 */
+ (UNMutableNotificationContent *)contentWithTitle:(NSString *)title
                                          subTitle:(NSString *)subTitle
                                              body:(NSString *)body
                                             badge:(NSInteger)badge
                                             sound:(UNNotificationSound *)sound
                                        attachment:(UNNotificationAttachment *)attachment;
/**
 @param attachments 多个附件
 */
+ (UNMutableNotificationContent *)contentWithTitle:(NSString *)title
                                          subTitle:(NSString *)subTitle
                                              body:(NSString *)body
                                             badge:(NSInteger)badge
                                             sound:(UNNotificationSound *)sound
                                       attachments:(NSArray<UNNotificationAttachment *> *)attachments;
#pragma mark --- NSDateComponents

/**
 日期组件

 @param date 日期
 @return 返回一个带有年月日时分秒的日期组件 不会重复
 */
+ (NSDateComponents *)componentsWithDate:(NSDate *)date;

/**
 日期组件

 @param date 日期
 @param weekday 指定星期几  1-7对应星期日-星期六
 @return 周时分秒  每周重复
 */
+ (NSDateComponents *)componentsWithDate:(NSDate *)date weekday:(NSInteger)weekday;

/**
 日期组件

 @param date 日期
 @return 时分秒 每日重复
 */
+ (NSDateComponents *)componentsWithEveryDayWithDate:(NSDate *)date;
/**
 日期组件
 
 @param date 日期
 @return 时分秒 每周重复
 */
+ (NSDateComponents *)componentsWithEveryWeekWithDate:(NSDate *)date;
/**
 日期组件
 
 @param date 日期
 @return 时分秒 每月重复
 */
+ (NSDateComponents *)componentsWithEveryMonthWithDate:(NSDate *)date;
/**
 日期组件
 
 @param date 日期
 @return 时分秒 每年重复
 */
+ (NSDateComponents *)componentsWithEveryYearWithDate:(NSDate *)date;


#pragma mark --- UNNotificationTrigger

/**
 通知触发器

 @param components 日期组件
 @param repeats 是否重复
 */
+ (UNNotificationTrigger *)triggerWithDateComponents:(NSDateComponents *)components
                                             repeats:(BOOL)repeats;

/**
 通知触发器

 @param interval 通知间隔
 @param repeats 是否重复
 */
+ (UNNotificationTrigger *)triggerWithTimeInterval:(NSTimeInterval)interval
                                           repeats:(BOOL)repeats;

/**
 通知触发器

 @param region 地理信息
 @param repeats 是否重复
 */
+ (UNNotificationTrigger *)triggerWithRegion:(CLRegion *)region
                                     repeats:(BOOL)repeats;










@end
